package com.hspedu.newData.dmsxl.数组.前缀和;
/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-20 
 * @Version: 1.0
 */

public class LC2485找出中枢整数 {

    public int pivotInteger(int n) {

        if (n==1) return 1;


        int sum = (n-1)*n/2;

        int count = 0;
        for (int i = 1; i < n; i++) {
            count = count + i;
            if ((count*2 - i)==sum){
                return i;
            }
        }
        return -1;

    }

}
